package com.party.core.service.member.impl;

import com.party.common.paging.Page;
import com.party.common.utils.StringUtils;
import com.party.common.utils.UUIDUtils;
import com.party.core.dao.read.member.ThirdPartyUserInfoReadDao;
import com.party.core.dao.write.member.ThirdPartyUserInfoWriteDao;
import com.party.core.model.member.ThirdPartyUserInfo;
import com.party.core.service.member.IThirdPartyUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * @ClassName ThirdPartyUserInfoService
 * @Description
 * @Author yifeng
 * @Date 2019/1/24 15:51
 **/
@Service
public class ThirdPartyUserInfoService implements IThirdPartyUserInfoService {
    @Autowired
    private ThirdPartyUserInfoReadDao thirdPartyUserInfoReadDao;

    @Autowired
    private ThirdPartyUserInfoWriteDao thirdPartyUserInfoWriteDao;

    @Override
    public String insert(ThirdPartyUserInfo thirdPartyUserInfo) {
        if (StringUtils.isEmpty(thirdPartyUserInfo.getId())) {
            thirdPartyUserInfo.setId(UUIDUtils.generateRandomUUID());
        }
        if (null == thirdPartyUserInfo.getCreateDate()) {
            thirdPartyUserInfo.setCreateDate(new Date());
        }
        boolean result = thirdPartyUserInfoWriteDao.insert(thirdPartyUserInfo);
        if (result) {
            return thirdPartyUserInfo.getId();
        }
        return null;
    }

    @Override
    public boolean update(ThirdPartyUserInfo thirdPartyUserInfo) {
        return thirdPartyUserInfoWriteDao.update(thirdPartyUserInfo);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        if (StringUtils.isNotEmpty(id)) {
            return thirdPartyUserInfoWriteDao.delete(id);
        }
        return false;
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public ThirdPartyUserInfo get(String id) {
        return thirdPartyUserInfoReadDao.get(id);
    }

    @Override
    public List<ThirdPartyUserInfo> listPage(ThirdPartyUserInfo thirdPartyUserInfo, Page page) {
        return null;
    }

    @Override
    public List<ThirdPartyUserInfo> list(ThirdPartyUserInfo thirdPartyUserInfo) {
        return null;
    }

    @Override
    public List<ThirdPartyUserInfo> batchList(Set<String> ids, ThirdPartyUserInfo thirdPartyUserInfo, Page page) {
        return null;
    }

    @Override
    public ThirdPartyUserInfo findByThirdPartyUserId(String thirdPartyUserId) {
        return thirdPartyUserInfoReadDao.findByThirdPartyUserId(thirdPartyUserId);
    }

    @Override
    public boolean deleteByThirdPartyUserId(String thirdPartyUserId) {
        return thirdPartyUserInfoWriteDao.deleteByThirdPartyUserId(thirdPartyUserId);
    }
}
